package kr.or.kosta.otr.service.companyservice;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.annotation.Resource;

import kr.or.kosta.otr.persistence.company.CompanyDao;
import kr.or.kosta.otr.persistence.companyreview.CompanyReviewDao;
import kr.or.kosta.otr.persistence.companyreviewverify.CompanyReviewVerifyDao;
import kr.or.kosta.otr.persistence.industry.IndustryDao;
import kr.or.kosta.otr.persistence.region.RegionDao;
import kr.or.kosta.otr.persistence.report.ReportDao;
import kr.or.kosta.otr.persistence.score.ScoreDao;
import kr.or.kosta.otr.utill.CompanyListVO;
import kr.or.kosta.otr.utill.CompanyPagingBean;
import kr.or.kosta.otr.vo.CompanyReviewVO;
import kr.or.kosta.otr.vo.CompanyVO;
import kr.or.kosta.otr.vo.IndustryVO;
import kr.or.kosta.otr.vo.RegionVO;
import kr.or.kosta.otr.vo.ReportVO;

import org.springframework.stereotype.Service;

@Service("CompanyService")
public class CompanyServiceImpl implements CompanyService{
	
	@Resource(name="CompanyReviewVerifyDao")
	CompanyReviewVerifyDao companyReviewVerifyDao;
	
	@Resource(name="CompanyDao")
	private CompanyDao companyDao;

	@Resource(name="CompanyReviewDao")
	private CompanyReviewDao companyReviewDao;
	
	@Resource(name="IndustryDao")
	private IndustryDao industryDao;
	
	@Resource(name="RegionDao")
	private RegionDao regionDao;
	
	@Resource(name="ScoreDao")
	private ScoreDao scoreDao;
	
	@Resource(name="ReportDao")
	private ReportDao reportDao;
 	@Override
	public ArrayList<CompanyVO> getCompanyInfo(HashMap<String, Object> map)
			throws SQLException {
		
		return companyDao.getCompanyInfo(map);
	}

	@Override
	public ArrayList<IndustryVO> getAllIndustry() throws SQLException {
		
		return industryDao.getAllIndustry();
	}

	@Override
	public ArrayList<RegionVO> getAllRegion() throws SQLException {
		
		return regionDao.getAllRegion();
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByPromotion()
			throws SQLException {
		
		return scoreDao.getAllCompanyOrderByPromotion();
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByWelfare() throws SQLException {
		
		return scoreDao.getAllCompanyOrderByWelfare();
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByCulture() throws SQLException {
		
		return scoreDao.getAllCompanyOrderByCulture();
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByHoliday() throws SQLException {
		
		return scoreDao.getAllCompanyOrderByHoliday();
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByExecutive()
			throws SQLException {
		
		return scoreDao.getAllCompanyOrderByExecutive();
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByOverdue() throws SQLException {
		
		return scoreDao.getAllCompanyOrderByOverdue();
	}

	@Override
	public CompanyReviewVO getCompanyReviewByScoreId(int scoreId)
			throws SQLException {
		
		return companyReviewDao.getCompanyReviewByScoreId(scoreId);
	}

	@Override
	public CompanyVO getOneCompany(int companyId) throws SQLException {
		
		return companyDao.getOneCompany(companyId);
	}

	@Override
	public ArrayList<CompanyReviewVO> getAllCompanyReview() throws SQLException {
		
		return companyReviewDao.getAllCompanyReview();
	}

	@Override
	public float getTotalScoreOfChance(int companyId) throws SQLException {
	
		return scoreDao.getTotalScoreOfChance(companyId);
	}

	@Override
	public float getTotalScoreOfWelfare(int companyId) throws SQLException {
		
		return scoreDao.getTotalScoreOfWelfare(companyId);
	}

	@Override
	public float getTotalScoreOfCulture(int companyId) throws SQLException {
		
		return scoreDao.getTotalScoreOfCulture(companyId);
	}

	@Override
	public float getTotalScoreOfHoliday(int companyId) throws SQLException {
		
		return scoreDao.getTotalScoreOfHoliday(companyId);
	}

	@Override
	public float getTotalScoreOfExecutive(int companyId) throws SQLException {

		return scoreDao.getTotalScoreOfExecutive(companyId);
	}

	@Override
	public float getTotalScoreOfOverdue(int companyId) throws SQLException {
		
		return scoreDao.getTotalScoreOfOverdue(companyId);
	}

	@Override
	public float getTotalScoreOfTotal(int companyId) throws SQLException {
		
		return scoreDao.getTotalScoreOfTotal(companyId);
	}

	@Override
	public ArrayList<CompanyVO> customCompany(HashMap<String, Object> map)
			throws SQLException {
		// TODO Auto-generated method stub
		return companyDao.customCompany(map);
	}

	@Override
	public int isExistCompanyReviewVerifyByCompanyId(int companyId)
			throws SQLException {
		// TODO Auto-generated method stub
		return companyReviewVerifyDao.isExistCompanyReviewVerifyByCompanyId(companyId);
	}

	@Override
	public int writeReport(ReportVO vo) throws SQLException {
		
		return reportDao.writeReport(vo);
	}

	public CompanyListVO getCompanyInfoPage(HashMap<String, Object> map,HashMap<String, Object> tmap)
			throws SQLException {
		// TODO Auto-generated method stub
		int pn=1;
		String pageNo = (String) map.get("value");
		if(pageNo!=null){
			pn=Integer.parseInt(pageNo);
		}
		map.put("value", pn);
		ArrayList<CompanyVO> list=companyDao.getCompanyInfoPage(map);
		int totalContents=companyDao.getCompanyInfoTotal(tmap);
		CompanyPagingBean pb=new CompanyPagingBean(totalContents, pn);

		return new CompanyListVO(list, pb);
	}
}
